package cn.doitedu.rtmk.demo7.groovy_demo;

import groovy.lang.GroovyClassLoader;

public class Main {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {


        String code = "package cn.doitedu.rtmk.demo7\n" +
                "\n" +
                "class RuleModeXCalculator implements IRuleCalculator{\n" +
                "    void calc(){\n" +
                "        System.out.println(\"hello world\")\n" +
                "    }\n" +
                "}";

        GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
        Class aClass = groovyClassLoader.parseClass(code);
        IRuleCalculator calculator = (IRuleCalculator) aClass.newInstance();

        calculator.calc();


    }

}
